<%--
  Created by IntelliJ IDEA.
  User: alen
  Date: 2024/8/17
  Time: 20:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>融资管理系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
</head>
<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span class="tpl-header-list-user-nick">禁言小张</span><span class="tpl-header-list-user-ico"> <img
                        src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="login.jsp"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
        </ul>
    </div>
    <style>
        .ele-dot-text {
            width: 45px;
            display: inline-block;
            margin-left: 20px;
        }

        .ele-dot-status {

            width: 8px;
            height: 8px;
            display: inline-block;
            border-radius: 50%;
            line-height: 10px;
        }

        .ele-dot-status-success {
            background: #52c41a;
        }

        .ele-dot-status-error {
            background: #ff4d4f;
        }

        .ele-dot-status-info {
            background: #1890ff;
        }
    </style>
    <script type="text/javascript" src="assets/js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        var enterprise_id = null;
        var buttonName = null;
        var no = null;
        var instituty_id = null;
        var amount_low = null;
        var amount_high = null;
        var create_time = null;
        var status = null;

        $(document).ready(function () {
            if($("[name='hiddentxt']").val() != "null")
                enterprise_id=$("[name='hiddentxt']").val();
            $.get("financing/queryAllInstituty",function (instituty1) {
                JSON.stringify(instituty1);
                queryAllInstituty(instituty1);

            });
            $("[type='button']").click(function () {
                buttonName = $(this).attr("name");
                // alert(buttonName);
            });

            $(document).on("click", "#clickPlace", function () {
                financeCondition();
                // alert(no + "：" + instituty_id + "：" + amount_low + "：" + amount_high + "：" + create_time + "：" + status);
                $.get("financing/queryByFinancingCondition", {
                    "enterprise_id":enterprise_id,
                    "no": no,
                    "instituty_id": instituty_id,
                    "amount_low": amount_low,
                    "amount_high": amount_high,
                    "create_time": create_time,
                    "status": status
                }, function (pageHelper) {
                    JSON.stringify(pageHelper);
                    forFinancing(pageHelper.list);
                    showButton(pageHelper);
                });
            });
        });
        function queryAllInstituty(instituty1) {
            $("#id2").empty();
            $("<option value='-1' disabled>请选择收单企业</option>").appendTo("#id2");
            $("<option value='0' >全部</option>").appendTo($("#id2"));
            for (var i = 0; i <instituty1.length;i++ ){
               $("<option value='"+instituty1[i].id+"'>"+instituty1[i].name+"</option>").appendTo("#id2");
            }
        }
        function forFinancing(financingAndInstituty) {
            $("#doc-modal-list").empty();
            for (var i = 0; i < financingAndInstituty.length; i++) {
                    $("<tr data-id='2' id='"+financingAndInstituty[i].id+"'>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].no + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].amount + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].cost + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].instituty_name + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].create_time + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].receipt_time + "(剩余" + financingAndInstituty[i].instituty_receipt_day + "天)</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].uplink_address + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].status + "</td>" +
                    "<td class='am-hide-sm-only'>" + financingAndInstituty[i].progress_status + "</td>" +
                    "<td><a href='finance-detail.jsp?id="+financingAndInstituty[i].id+"' title='详情'>详情</a></td>" +
                    "</tr>").appendTo("#doc-modal-list");
            }

        }

        function financeCondition() {
            no = $("#id1").val();
            instituty_id = $("#id2").val();
            amount_low = $("#id3").val();
            amount_high = $("#id4").val();
            create_time = $("#id5").val();
            status = buttonName;
            if (buttonName === "全部") {
                status = null;
            }
            if (instituty_id == 0) {
                instituty_id = null;
            }
        }

        //根据pageHelper，动态获得分页按钮上一页 下一页
        function showButton(pageHelper) {
            $("#button_control").empty();/*<li><a href="#">»</a></li>*/
            if (pageHelper.whichPage != 1){
                $("<li><input id='pageBtn' type='button' value='«' name='" + (pageHelper.whichPage - 1) + "'/></li>").appendTo($("#button_control"));
            }
            for(var i = 1; i <= pageHelper.pageNum; i++){
                if (i != pageHelper.whichPage)
                    $("<li><input id='pageBtn' type='button' value='"+i+"' name='" + i + "'/></li>").appendTo($("#button_control"));
            }
            if (pageHelper.whichPage != pageHelper.pageNum){
                $("<li><input id='pageBtn' type='button' value='»' name='" + (pageHelper.whichPage + 1) + "'/></li>").appendTo($("#button_control"));
            }
            $("<input type='text' style='width: 70px; height: 30px; font-size: 12px' value= '" + "当前" + pageHelper.whichPage + "/" + pageHelper.pageNum + "' disabled/>").appendTo($("#button_control"));
        }
        //为分页按钮，绑定单击事件
        $(document).on("click", "#pageBtn", function () {
            //获得下拉列表的value值
            var whichPage = $(this).attr("name");
            $.get("financing/queryByFinancingCondition", {
                "enterprise_id":enterprise_id,
                "no": no,
                "instituty_id": instituty_id,
                "amount_low": amount_low,
                "amount_high": amount_high,
                "create_time": create_time,
                "status": status,
                "whichPage":whichPage
            }, function (pageHelper) {
                JSON.stringify(pageHelper);
                forFinancing(pageHelper.list);
                showButton(pageHelper);
            });
        });
    </script>
</header>
<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-table"></i>
                        <span>凭证管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display:block">
                        <li>
                            <a href="finance-list.jsp" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>融资列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-wpforms"></i>
                        <span>我的凭证</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="my-ticket-list.jsp">
                                <i class="am-icon-angle-right"></i>
                                <span>我的凭证列表</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            融资列表
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">凭证管理</a></li>
            <li class="am-active">融资列表</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="tpl-block" id="clickPlace">
                <div class="am-g">
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">凭证编号</span>
                                </span>
                            <input type="text" id="id1" class="am-form-field" placeholder="&nbsp;&nbsp;请输入凭证编号"
                                   style="border: 1px solid #c2cad8;width: 68%;border-radius: 3px;">
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-form-group">
                            <span style="font-size: 14px;">金融机构</span>
                            <select id="id2" data-am-selected="{btnSize: 'sm'}">
                                <option value="-1" DISABLED>请选择收单企业</option>
                                <option value="0">全部金融机构</option>
                                <option value="1">中国工商银行</option>
                                <option value="2">中国农业银行</option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3" style="margin-left: -10px;">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">融资金额</span>
                                </span>
                            <input id="id3" type="text" class="am-form-field" placeholder="&nbsp;&nbsp;最低金额(万)"
                                   style="border: 1px solid #c2cad8;width: 32%;border-radius: 3px;">
                            <div class="am-form-field"
                                 style="width: 0%; border-radius: 3px;border: none;margin-left: 10px;">~
                            </div>
                            <input id="id4" type="text" class="am-form-field" placeholder="&nbsp;&nbsp;最高金额(万)"
                                   style="border: 1px solid #c2cad8;width: 32%;border-radius: 3px;margin-left: 20px;">
                        </div>
                    </div>
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                                <span class="am-input-group-btn">
                                    <span
                                            style="font-size: 14px;margin-right: 8px;margin-left: 8px">申请日期</span>
                                </span>
                            <input type="text" id="id5" class="am-form-field" data-am-datepicker
                                   placeholder="&nbsp;&nbsp;请选择日期"
                                   style="border: 1px solid #c2cad8;width: 68%;border-radius: 3px;">
                        </div>
                    </div>
                </div>
                <div class="am-g" style="margin-top: 15px;">
                    <div class="am-u-sm-6 am-u-md-3">
                        <div class="am-input-group am-input-group-sm status-type">
                                <span class="am-input-group-btn">
                                    <span style="font-size: 14px;margin-right: 8px;margin-left: 8px">处理状态</span>
                                </span>
                            <div class="am-btn-group am-btn-group-sm">
                                <button type="button" id="s1" name="0" class="am-btn am-btn-primary am-radius">全部</button>
                                <button type="button" id="s2" name="1" class="am-btn am-btn-default">成功</button>
                                <button type="button" id="s3" name="2" class="am-btn am-btn-default">融资中</button>
                                <button type="button" id="s4" name="3" class="am-btn am-btn-default">失败</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table class="am-table am-table-striped am-table-hover table-main">
                            <thead>
                            <tr>
                                <th class="table-title">凭证编号</th>
                                <th class="table-author am-hide-sm-only">融资本金（元）</th>
                                <th class="table-author am-hide-sm-only">（预计）融资成本（元）</th>
                                <th class="table-date am-hide-sm-only">金融机构</th>
                                <th class="table-date am-hide-sm-only">申请日期</th>
                                <th class="table-date am-hide-sm-only">（预计）放款日期</th>
                                <th class="table-date am-hide-sm-only">上链地址</th>
                                <th class="table-date am-hide-sm-only">处理状态</th>
                                <th class="table-date am-hide-sm-only">进度状态</th>
                                <th class="table-set">操作</th>
                            </tr>
                            </thead>
                            <tbody id="doc-modal-list">
                            </tbody>
                        </table>
                        <div class="am-cf">
                            <div class="am-fr">
                                <ul id="button_control" class="am-pagination tpl-pagination">
                                    <li class="am-disabled"><a href="#">«</a></li>
                                    <li class="am-active"><a href="#">1</a></li>
                                    <li><a href="#">2</a></li>
                                    <li><a href="#">3</a></li>
                                    <li><a href="#">4</a></li>
                                    <li><a href="#">5</a></li>
                                    <li><a href="#">»</a></li>
                                </ul>
                            </div>
                        </div>
                        <hr>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script>
    // 撤销二次确认
    $(function () {
        //状态按钮样式切换
        $('.status-type').find('button').on('click', function () {
            let statusTypeBtnArr = $('.status-type').find('button');
            for (let i = 0; i < statusTypeBtnArr.length; i++) {
                statusTypeBtnArr.eq(i).removeClass('am-btn-primary');
            }
            $(this).addClass('am-btn-primary');
        });
    });
</script>
<input type="hidden" name="hiddentxt" value="<%=request.getParameter("enterprise_id")%>">
</body>

</html>
